#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include <QDebug>
#include <QInputDialog>
#include <QStringList>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //通过按钮获取到条目输入框，然后在输入框中选择想要的条数，然后后台进行打印
    QPushButton* button = new QPushButton("点击按钮选择条目",this);
    QInputDialog* idilg = new QInputDialog(this);
    connect(button,&QPushButton::clicked,[=](){
        QStringList items;
        items << tr("spring") << tr("summer") << tr("fall") << tr("winter");
        QString item = idilg->getItem(this,"条目输入框","Item",items);
        qDebug() << "选择的条目是: " << item;
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

